# 查询sqllite数据
import sqlite3

DBNAME = r".\birthdayPush\time_db.db"

def query_data(sql, type=1):
    conn = sqlite3.connect(DBNAME)
    cursor = conn.cursor()
    cursor.execute(sql)
    if type == 1:
        data = cursor.fetchone()
    else:
        data = cursor.fetchall()
    cursor.close()
    conn.close()
    return data


# 更新sqllite数据
def sqllite_update(sql, value):
    conn = sqlite3.connect(DBNAME)
    cursor = conn.cursor()
    cursor.execute(sql, value)
    cursor.close()
    conn.commit()
    conn.close()


# 插入sqllite数据
def sqllite_create(sql):
    conn = sqlite3.connect(DBNAME)
    cursor = conn.cursor()
    cursor.execute(sql)
    cursor.close()
    conn.commit()
    conn.close()